# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=dbc-parser-cpp
pkgver=0.1.1.r94.0f3b22b
pkgrel=1
_commit=0f3b22b3fe124976a86a85fcd1bfdd55c20ca428
pkgdesc='A DBC file parsing library written in C++'
arch=(loong64 x86_64)
license=(MIT)
url='https://github.com/LinuxDevon/dbc_parser_cpp'
depends=()
makedepends=(git cmake catch2)
source=(git+https://github.com/LinuxDevon/dbc_parser_cpp#commit=$_commit)
sha256sums=('SKIP')

pkgver() {
  cd ${pkgname//-/_}
  git describe --tags | sed 's/^v//; s/-/.r/; s/-g/./'
}

build() {
  cmake -B build -S ${pkgname//-/_} \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_CXX_FLAGS="$CXXFLAGS -ffat-lto-objects" \
    -DENABLE_TESTS=OFF
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -Dm644 ${pkgname//-/_}/LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname
}
